import 'package:sweet_app/model/message_model.dart';

class AddHistory {
  final String id;

  final String fId;

  final String message;

  final bool addFlag;

  final DateTime time;

  AddHistory(
      {this.id, this.fId, this.message, this.addFlag = false, this.time});

  static AddHistory fromJson(Map<String, dynamic> map) {
    return AddHistory(
        id: map["id"],
        fId: map["fId"],
        message: map["message"],
        addFlag: map["addFlag"]);
  }

  @override
  String toString() {
    return 'AddHistory{id: $id, fId: $fId, message: $message, addFlag: $addFlag}';
  }

  static AddHistory fromMessage(MessageModel model) {
    return AddHistory(
        id: model.id,
        fId: model.fromUser,
        message: model.content,
        time: DateTime.fromMillisecondsSinceEpoch(int.parse(model.time)));
  }
}
